home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
2510.ZIP
/
TRSOURCE.EXE
/
_TR_HTOI.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-22
|
723b
|
39 lines
/*********
*
* _TR_HTOI.C
*
* by Ralph Davis
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
* SYNTAX: _tr_htoi(cp)
* char *cp;
*
* RETURN: integer equivalent of cp
*
*********/
#include "trlib.h"
_tr_htoi(s) /* dec() internal function */
char *s;
{
int hexdigit, i, n;
n = 0;
for (i = 0; i < _tr_strlen(s); i++)
{
if (s[i] >= '0' && s[i] <= '9')
hexdigit = s[i] - '0';
else if (s[i] >= 'a' && s[i] <= 'f')
hexdigit = s[i] - 'a' + 10;
else if (s[i] >= 'A' && s[i] <= 'F')
hexdigit = s[i] - 'A' + 10;
else
return(0);
n = 16 * n + hexdigit;
}
return(n);
}